define(['jquery', 'frontend/loginpop'], function ($, LoginPop) {

    var Controller = {

        //是否密码已验证
        passwordVerified: Config.passwordVerified,

        //初始化
        init: function () {
            console.log("LoginPop.logined ", LoginPop.logined);
            console.log("passwordVerified", Controller.passwordVerified);
            $("#my-study-room").click(function () {
                //未登陆时，跳转到登陆页
                if (LoginPop.logined == 0) {
                    window.location = "/index/user/login";
                    return false;
                }
                //没有验证过密码，打开密码验证窗口
                if (Controller.passwordVerified == 0) {
                    Controller.openVerifiedWindow();
                    return false;
                }

                window.location = "/index/user/index";
                return false;
            })
        },

        //打开密码验证窗口
        openVerifiedWindow: function () {
            Fast.api.open("/index/ai/passwordpop", "", {
                shadeClose: false,
                shade: [0.7, '#393D49'],
                area: ['500px', '200px'],
                maxmin: false,
                closeBtn: 0,
                callback: function (value) {
                    console.log(value);
                    if (value.code == "1") {
                        Controller.passwordVerified = 1;
                        console.log("passwordVerified", Controller.passwordVerified);
                        window.location = "/index/user/index";
                    }
                }
            });
        },
    };
    return Controller;
});
